
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <title>renderRoot · React源码解析</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.0">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-api/theme-api.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

         
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="render-root/throw-exception.html" />
    
    
    <link rel="prev" href="perform-unit-of-work.html" />
    

<script
  async
  src="https://www.googletagmanager.com/gtag/js?id=UA-49483742-5"
></script>
<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('js', new Date())

  gtag('config', 'UA-49483742-5')
</script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    基础
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../api/react.html">
            
                <a href="../api/react.html">
            
                    
                    React API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../api/react-element.html">
            
                <a href="../api/react-element.html">
            
                    
                    ReactElement
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../api/react-children.html">
            
                <a href="../api/react-children.html">
            
                    
                    React Children
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../api/react-structure.html">
            
                <a href="../api/react-structure.html">
            
                    
                    React 中的数据结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    创建更新
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../update/react-dom-render.html">
            
                <a href="../update/react-dom-render.html">
            
                    
                    ReactDOM.render
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../update/set-state.html">
            
                <a href="../update/set-state.html">
            
                    
                    setState & forceUpdate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../update/expiration-time.html">
            
                <a href="../update/expiration-time.html">
            
                    
                    expirationTime 计算
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    任务调度
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="scheduler-global.html">
            
                <a href="scheduler-global.html">
            
                    
                    全局变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="schedule-work.html">
            
                <a href="schedule-work.html">
            
                    
                    scheduleWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="scheduler-pkg.html">
            
                <a href="scheduler-pkg.html">
            
                    
                    react-scheduler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="perform-work.html">
            
                <a href="perform-work.html">
            
                    
                    performWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="perform-unit-of-work.html">
            
                <a href="perform-unit-of-work.html">
            
                    
                    performUnitOfWork
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.6" data-path="render-root.html">
            
                <a href="render-root.html">
            
                    
                    renderRoot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.6.1" data-path="render-root/throw-exception.html">
            
                <a href="render-root/throw-exception.html">
            
                    
                    throwException
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="begin-work.html">
            
                <a href="begin-work.html">
            
                    
                    beginWork
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.7.1" data-path="begin-work/mount-indeterminate-component.html">
            
                <a href="begin-work/mount-indeterminate-component.html">
            
                    
                    mountIndeterminateComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.2" data-path="begin-work/mount-lazy-component.html">
            
                <a href="begin-work/mount-lazy-component.html">
            
                    
                    mountLazyComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.3" data-path="begin-work/update-functional-component.html">
            
                <a href="begin-work/update-functional-component.html">
            
                    
                    updateFunctionalComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.4" data-path="begin-work/update-class-component.html">
            
                <a href="begin-work/update-class-component.html">
            
                    
                    updateClassComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.5" data-path="begin-work/update-host-root.html">
            
                <a href="begin-work/update-host-root.html">
            
                    
                    updateHostRoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.6" data-path="begin-work/update-host-component.html">
            
                <a href="begin-work/update-host-component.html">
            
                    
                    updateHostComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.7" data-path="begin-work/update-host-text.html">
            
                <a href="begin-work/update-host-text.html">
            
                    
                    updateHostText
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.8" data-path="../feature/Suspense-component.md">
            
                <span>
            
                    
                    updateSuspenseComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.9" data-path="begin-work/update-portal-component.html">
            
                <a href="begin-work/update-portal-component.html">
            
                    
                    updatePortalComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.10" data-path="begin-work/update-forward-ref.html">
            
                <a href="begin-work/update-forward-ref.html">
            
                    
                    updateForwardRef
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.11" data-path="begin-work/update-fragment.html">
            
                <a href="begin-work/update-fragment.html">
            
                    
                    updateFragment
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.12" data-path="begin-work/update-mode.html">
            
                <a href="begin-work/update-mode.html">
            
                    
                    updateMode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.13" data-path="begin-work/update-profiler.html">
            
                <a href="begin-work/update-profiler.html">
            
                    
                    updateProfiler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.14" data-path="begin-work/update-context-provider.html">
            
                <a href="begin-work/update-context-provider.html">
            
                    
                    updateContextProvider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.15" data-path="begin-work/update-context-consumer.html">
            
                <a href="begin-work/update-context-consumer.html">
            
                    
                    updateContextConsumer
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="reconcile-children.html">
            
                <a href="reconcile-children.html">
            
                    
                    reconcileChildren
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.8.1" data-path="reconcile-children/single.html">
            
                <a href="reconcile-children/single.html">
            
                    
                    调和单个节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.2" data-path="reconcile-children/array.html">
            
                <a href="reconcile-children/array.html">
            
                    
                    调和列表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    commit 阶段
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../commit-phase/commit-root.html">
            
                <a href="../commit-phase/commit-root.html">
            
                    
                    commitRoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../commit-phase/invokeGuardedCallback.html">
            
                <a href="../commit-phase/invokeGuardedCallback.html">
            
                    
                    invokeGuardedCallback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../commit-phase/commitBeforeMutationLifecycles.html">
            
                <a href="../commit-phase/commitBeforeMutationLifecycles.html">
            
                    
                    commitBeforeMutationLifecycles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../commit-phase/commit-all-host-effects.html">
            
                <a href="../commit-phase/commit-all-host-effects.html">
            
                    
                    commitAllHostEffects
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.4.1" data-path="../commit-phase/host-effects/CommitPlacement.html">
            
                <a href="../commit-phase/host-effects/CommitPlacement.html">
            
                    
                    commitPlacement
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.2" data-path="../commit-phase/host-effects/CommitWork.html">
            
                <a href="../commit-phase/host-effects/CommitWork.html">
            
                    
                    commitWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.3" data-path="../commit-phase/host-effects/CommitDeletion.html">
            
                <a href="../commit-phase/host-effects/CommitDeletion.html">
            
                    
                    commitDeletion
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../commit-phase/commit-all-lifecycles.html">
            
                <a href="../commit-phase/commit-all-lifecycles.html">
            
                    
                    commitAllLifecycle
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    功能
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../features/context.html">
            
                <a href="../features/context.html">
            
                    
                    context
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../features/hydrate.html">
            
                <a href="../features/hydrate.html">
            
                    
                    hydrate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../features/ref.html">
            
                <a href="../features/ref.html">
            
                    
                    ref
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../features/event-injection.html">
            
                <a href="../features/event-injection.html">
            
                    
                    事件系统初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../features/event-bind.html">
            
                <a href="../features/event-bind.html">
            
                    
                    事件绑定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../features/event-dispatch.html">
            
                <a href="../features/event-dispatch.html">
            
                    
                    事件触发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../features/event-create-event-object.html">
            
                <a href="../features/event-create-event-object.html">
            
                    
                    事件对象生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../features/Suspense-component.html">
            
                <a href="../features/Suspense-component.html">
            
                    
                    Suspense
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../features/suspense.html">
            
                <a href="../features/suspense.html">
            
                    
                    挂起任务的含义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../features/suspense-lazy.html">
            
                <a href="../features/suspense-lazy.html">
            
                    
                    lazy 组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Hooks
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../hooks/hooks-start.html">
            
                <a href="../hooks/hooks-start.html">
            
                    
                    开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../hooks/hooks-use-state.html">
            
                <a href="../hooks/hooks-use-state.html">
            
                    
                    useState
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../hooks/hooks-use-effect.html">
            
                <a href="../hooks/hooks-use-effect.html">
            
                    
                    useEffect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../hooks/hooks-others.html">
            
                <a href="../hooks/hooks-others.html">
            
                    
                    其他API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../hooks/hooks-common.html">
            
                <a href="../hooks/hooks-common.html">
            
                    
                    通用API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <form
            action="https://buttondown.email/api/emails/embed-subscribe/Jokcy"
            method="post"
            target="popupwindow"
            onsubmit="window.open('https://buttondown.email/Jokcy', 'popupwindow')"
            class="buttondown-form"
            >
            <input type="email" name="email" id="bd-email" placeholder="(your@email.com)">
            <input type="hidden" value="1" name="embed"/>
            <button type="submit">订阅我</button>
        </form>
    </li>
</ul>

                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                 
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >renderRoot</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="renderroot">renderRoot</h1><div class="api-method"><div class="api-method-definition"><p>&#x8FD9;&#x5927;&#x6982;&#x662F; React &#x6E90;&#x7801;&#x4E2D;&#x6211;&#x770B;&#x5230;&#x8FC7;&#x6700;&#x957F;&#x7684;&#x65B9;&#x6CD5;&#x4EE3;&#x7801;&#x4E86;&#x3002;&#x3002;&#x3002;&#x8FD9;&#x91CC;&#x5C55;&#x793A;&#x7684;&#x6211;&#x628A;&#x4E00;&#x4E9B;&#x4E0D;&#x662F;&#x7279;&#x522B;&#x91CD;&#x8981;&#x7684;&#x6BD4;&#x5982;&#x63D0;&#x9192;&#x4EE3;&#x7801;&#x6216;&#x8005;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x4EE3;&#x7801;&#x5220;&#x4E86;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x8FD8;&#x6709;&#x6CE8;&#x91CA;&#x4E5F;&#x5220;&#x4E86;&#x633A;&#x591A;&#x3002;</p><p>&#x9996;&#x5148;&#x662F;&#x4E00;&#x4E2A;&#x5224;&#x65AD;&#x662F;&#x5426;&#x9700;&#x8981;&#x521D;&#x59CB;&#x5316;&#x53D8;&#x91CF;&#x7684;&#x5224;&#x65AD;</p><pre><code class="lang-js"><span class="hljs-keyword">if</span> (
  expirationTime !== nextRenderExpirationTime ||
  root !== nextRoot ||
  nextUnitOfWork === <span class="hljs-literal">null</span>
) {
  <span class="hljs-comment">// Reset the stack and start working from the root.</span>
  resetStack()
  nextRoot = root
  nextRenderExpirationTime = expirationTime
  nextUnitOfWork = createWorkInProgress(
    nextRoot.current,
    <span class="hljs-literal">null</span>,
    nextRenderExpirationTime,
  )
  root.pendingCommitExpirationTime = NoWork
}</code></pre>
<p>&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x5224;&#x65AD;&#x662F;&#x4EC0;&#x4E48;&#x610F;&#x601D;&#x5462;&#xFF1F;&#x4ED6;&#x5224;&#x65AD;&#x7684;&#x60C5;&#x51B5;&#x662F;&#x662F;&#x5426;&#x6709;&#x65B0;&#x7684;&#x66F4;&#x65B0;&#x8FDB;&#x6765;&#x4E86;&#x3002;&#x5047;&#x8BBE;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;<em>&#x4E0A;&#x4E00;&#x4E2A;&#x4EFB;&#x52A1;&#x56E0;&#x4E3A;&#x65F6;&#x95F4;&#x7247;&#x7528;&#x5B8C;&#x4E86;&#x800C;&#x4E2D;&#x65AD;&#x4E86;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;<code>nextUnitOfWork</code>&#x662F;&#x6709;&#x5DE5;&#x4F5C;&#x7684;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x5982;&#x679C;&#x4E0B;&#x4E00;&#x4E2A;<code>requestIdleCallback</code>&#x8FDB;&#x6765;&#x4E86;&#xFF0C;&#x4E2D;&#x9014;&#x6CA1;&#x6709;&#x65B0;&#x7684;&#x4EFB;&#x52A1;&#x8FDB;&#x6765;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E9B;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x90FD;&#x6CA1;&#x6709;&#x53D8;&#x8FC7;&#xFF0C;<code>root</code>&#x7684;<code>nextExpirationTimeToWorkOn</code>&#x80AF;&#x5B9A;&#x4E5F;&#x6CA1;&#x6709;&#x53D8;&#x5316;&#xFF0C;&#x90A3;&#x4E48;&#x4EE3;&#x8868;&#x662F;&#x7EE7;&#x7EED;&#x4E0A;&#x4E00;&#x6B21;&#x7684;&#x4EFB;&#x52A1;&#x3002;&#x800C;&#x5982;&#x679C;&#x6709;&#x65B0;&#x7684;&#x66F4;&#x65B0;&#x8FDB;&#x6765;&#xFF0C;&#x5219;&#x52BF;&#x5FC5;<code>nextExpirationTimeToWorkOn</code>&#x6216;&#x8005;<code>root</code>&#x4F1A;&#x53D8;&#x5316;&#xFF0C;&#x90A3;&#x4E48;&#x80AF;&#x5B9A;&#x9700;&#x8981;&#x91CD;&#x7F6E;&#x53D8;&#x91CF;</em></p><p><code>resetStack</code>&#x5982;&#x679C;&#x662F;&#x88AB;&#x4E2D;&#x65AD;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x4F1A;&#x63A8;&#x51FA;<code>context</code>&#x6808;&#xFF0C;&#x5173;&#x4E8E;<code>context</code>&#x53EF;&#x4EE5;&#x770B;<a href="context.md">&#x8FD9;&#x91CC;</a></p><p>TODO: &#x589E;&#x52A0;<code>context.md</code>&#x7684;&#x94FE;&#x63A5;</p><p>&#x7136;&#x540E;&#x5C31;&#x8FDB;&#x5165;&#x6574;&#x4F53;&#xFF0C;&#x8C03;&#x7528;<code>workLoop</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">workLoop</span>(<span class="hljs-params">isYieldy</span>) </span>{
  <span class="hljs-keyword">if</span> (!isYieldy) {
    <span class="hljs-comment">// Flush work without yielding</span>
    <span class="hljs-keyword">while</span> (nextUnitOfWork !== <span class="hljs-literal">null</span>) {
      nextUnitOfWork = performUnitOfWork(nextUnitOfWork)
    }
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-comment">// Flush asynchronous work until the deadline runs out of time.</span>
    <span class="hljs-keyword">while</span> (nextUnitOfWork !== <span class="hljs-literal">null</span> &amp;&amp; !shouldYield()) {
      nextUnitOfWork = performUnitOfWork(nextUnitOfWork)
    }
  }
}</code></pre>
<p><code>workLoop</code>&#x903B;&#x8F91;&#x5F88;&#x7B80;&#x5355;&#x7684;&#xFF0C;&#x53EA;&#x662F;&#x5224;&#x65AD;&#x662F;&#x5426;&#x9700;&#x8981;&#x7EE7;&#x7EED;&#x8C03;&#x7528;<code>performUnitOfWork</code>&#xFF0C;&#x90A3;&#x4E48;<code>performUnitOfWorkoop</code>&#x6211;&#x4EEC;&#x653E;&#x5230;<a href="perform-unit-of-work.html">&#x4E0B;&#x4E00;&#x8282;</a>&#x518D;&#x8BB2;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x770B;&#x5982;&#x679C;<code>catch</code>&#x5230;&#x9519;&#x8BEF;&#x4F1A;&#x600E;&#x4E48;&#x6837;&#x3002;</p><h3 id="if-catch-error">if catch error</h3><p>&#x9996;&#x5148;&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;<code>nextUnitOfWork</code>&#xFF0C;&#x5982;&#x679C;&#x662F;&#x9884;&#x671F;&#x9519;&#x8BEF;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x503C;&#x662F;&#x5B58;&#x5728;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#x4EE3;&#x8868;&#x662F; React &#x65E0;&#x6CD5;&#x9884;&#x671F;&#x7684;&#x9519;&#x8BEF;</p><p>&#x5982;&#x679C;&#x5B58;&#x5728;&#xFF0C;&#x5728;&#x5F00;&#x53D1;&#x65F6;&#x4F1A;&#x8C03;&#x7528;<code>replayUnitOfWork</code>&#x91CD;&#x653E;&#x4E00;&#x4E0B;&#x3002;&#x7136;&#x540E;&#x770B;&#x4E00;&#x4E0B;<code>nextUnitOfWork.return</code>&#x662F;&#x5426;&#x5B58;&#x5728;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#x4E5F;&#x662F;&#x65E0;&#x6CD5;&#x9884;&#x671F;&#x7684;&#x9519;&#x8BEF;&#x3002;&#x7136;&#x540E;&#x6267;&#x884C;<code>throwException</code>&#xFF0C;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x975E;&#x5E38;&#x91CD;&#x8981;&#xFF0C;&#x6211;&#x5355;&#x72EC;&#x5199;&#x4E00;&#x7BC7;&#x6587;&#x7AE0;&#x8FDB;&#x884C;&#x5206;&#x6790;&#xFF0C;<a href="render-root/throw-exception.html">&#x770B;&#x8FD9;&#x91CC;</a></p><p>&#x5728;<code>throwException</code>&#x4E4B;&#x540E;&#x4F1A;&#x76F4;&#x63A5;&#x8C03;&#x7528;<code>completeWork</code>&#x5F53;&#x524D;&#x7684;<code>nextUnitOfWork</code>&#xFF0C;&#x56E0;&#x4E3A;&#x4ED6;&#x5DF2;&#x7ECF;&#x62A5;&#x9519;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x5FC5;&#x8981;&#x518D;&#x6E32;&#x67D3;&#x4ED6;&#x7684;&#x5B50;&#x8282;&#x70B9;&#x4E86;&#x3002;</p><h3 id="&#x6536;&#x5C3E;">&#x6536;&#x5C3E;</h3><p>&#x5728;<code>workLoop</code>&#x6267;&#x884C;&#x5B8C;&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x8FDB;&#x5165;&#x6536;&#x5C3E;&#x9636;&#x6BB5;&#x4E86;&#x3002;</p><p>&#x9996;&#x5148;&#x5982;&#x679C;<code>didFatal</code>&#x4E3A;<code>true</code>&#xFF0C;&#x4EE3;&#x8868;&#x6709;&#x4E00;&#x4E2A;&#x65E0;&#x6CD5;&#x5904;&#x7406;&#x7684;&#x9519;&#x8BEF;&#xFF0C;&#x76F4;&#x63A5;&#x8C03;&#x7528;<code>onFatal</code>&#xFF0C;&#x4E0D;<code>commit</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onFatal</span>(<span class="hljs-params">root</span>) </span>{
  root.finishedWork = <span class="hljs-literal">null</span>
}</code></pre>
<p>&#x5982;&#x679C;<code>nextUnitOfWork !== null</code>&#xFF0C;&#x4EE3;&#x8868;&#x4EFB;&#x52A1;&#x6CA1;&#x6709;&#x6267;&#x884C;&#x5B8C;&#xFF0C;&#x662F;<code>yield</code>&#x4E86;&#xFF0C;&#x6267;&#x884C;<code>onYield</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onYield</span>(<span class="hljs-params">root</span>) </span>{
  root.finishedWork = <span class="hljs-literal">null</span>
}</code></pre>
<p>&#x5982;&#x679C;&#x4EE5;&#x4E0A;&#x90FD;&#x6CA1;&#x6709;&#xFF0C;&#x8BF4;&#x660E;&#x5DF2;&#x7ECF;<code>complete</code>&#x6574;&#x68F5;&#x6811;&#x4E86;&#xFF0C;&#x5982;&#x679C;<code>nextRenderDidError</code>&#x4EE3;&#x8868;&#x6709;&#x6355;&#x83B7;&#x5230;&#x53EF;&#x5904;&#x7406;&#x7684;&#x9519;&#x8BEF;</p><p>&#x8FD9;&#x65F6;&#x5019;&#x5148;&#x5224;&#x65AD;&#x662F;&#x5426;&#x6709;&#x4F18;&#x5148;&#x7EA7;&#x66F4;&#x4F4E;&#x7684;&#x4EFB;&#x52A1;&#xFF0C;&#x6709;&#x7684;&#x8BDD;&#x628A;&#x5F53;&#x524D;&#x7684;&#x6E32;&#x67D3;&#x65F6;&#x95F4;&#x8BBE;&#x7F6E;&#x8FDB;<code>suspendTime</code>&#xFF0C;&#x540C;&#x65F6;&#x8C03;&#x7528;<code>onSuspend</code></p><p>&#x5982;&#x679C;&#x4E0D;&#x7B26;&#x5408;&#x518D;&#x5224;&#x65AD;&#x662F;&#x5426;&#x5E27;&#x65F6;&#x95F4;&#x8D85;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x8D85;&#x65F6;&#x5E76;&#x4E14;&#x6CA1;&#x6709;<code>root.didError</code>&#xFF0C;&#x5E76;&#x4E14;&#x628A;<code>root.expirationTime</code>&#x8BBE;&#x7F6E;&#x4E3A;<code>Sync</code>&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528;<code>onSuspend</code>&#x3002;</p><p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x4ED6;&#x4EEC;&#x8C03;&#x7528;<code>onSuspend</code>&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7684;&#x90FD;&#x662F;<code>-1</code>&#xFF0C;&#x770B;<code>onSuspend</code>&#x7684;&#x903B;&#x8F91;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#x5176;&#x5B9E;&#x4EC0;&#x4E48;&#x90FD;&#x4E0D;&#x505A;&#x3002;&#x4EC0;&#x4E48;&#x90FD;&#x4E0D;&#x505A;&#x4EE3;&#x8868;&#x7740;&#xFF0C;&#x4ED6;&#x4EEC;&#x4E0D;&#x4F1A;&#x8BBE;&#x7F6E;<code>root.finishedWork</code>&#xFF0C;&#x90A3;&#x4E48;&#x8FD4;&#x56DE;&#x5230;&#x4E0A;&#x4E00;&#x5C42;&#x7684;<code>performWorkOnRoot</code>&#x7684;&#x65F6;&#x5019;</p><pre><code class="lang-js">finishedWork = root.finishedWork
<span class="hljs-keyword">if</span> (finishedWork !== <span class="hljs-literal">null</span>) {
  <span class="hljs-keyword">if</span> (!shouldYield()) {
    <span class="hljs-comment">// Still time left. Commit the root.</span>
    completeRoot(root, finishedWork, expirationTime)
  } <span class="hljs-keyword">else</span> {
    root.finishedWork = finishedWork
  }
}</code></pre>
<p>&#x5E76;&#x4E0D;&#x4F1A;&#x6267;&#x884C;<code>completeRoot</code>&#x4E5F;&#x5C31;&#x4E0D;&#x4F1A;<code>commit</code>&#xFF0C;&#x4F1A;&#x518D;&#x8FD4;&#x56DE;&#x5230;<code>performWork</code>&#x627E;&#x4E0B;&#x4E00;&#x4E2A;<code>root</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onSuspend</span>(<span class="hljs-params">
  root: FiberRoot,
  finishedWork: Fiber,
  suspendedExpirationTime: ExpirationTime,
  rootExpirationTime: ExpirationTime,
  msUntilTimeout: number,
</span>): <span class="hljs-title">void</span> </span>{
  root.expirationTime = rootExpirationTime
  <span class="hljs-keyword">if</span> (enableSuspense &amp;&amp; msUntilTimeout === <span class="hljs-number">0</span> &amp;&amp; !shouldYield()) {
    <span class="hljs-comment">// Don&apos;t wait an additional tick. Commit the tree immediately.</span>
    root.pendingCommitExpirationTime = suspendedExpirationTime
    root.finishedWork = finishedWork
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (msUntilTimeout &gt; <span class="hljs-number">0</span>) {
    <span class="hljs-comment">// Wait `msUntilTimeout` milliseconds before committing.</span>
    root.timeoutHandle = scheduleTimeout(
      onTimeout.bind(<span class="hljs-literal">null</span>, root, finishedWork, suspendedExpirationTime),
      msUntilTimeout,
    )
  }
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onTimeout</span>(<span class="hljs-params">root, finishedWork, suspendedExpirationTime</span>) </span>{
  <span class="hljs-keyword">if</span> (enableSuspense) {
    <span class="hljs-comment">// The root timed out. Commit it.</span>
    root.pendingCommitExpirationTime = suspendedExpirationTime
    root.finishedWork = finishedWork
    <span class="hljs-comment">// Read the current time before entering the commit phase. We can be</span>
    <span class="hljs-comment">// certain this won&apos;t cause tearing related to batching of event updates</span>
    <span class="hljs-comment">// because we&apos;re at the top of a timer event.</span>
    recomputeCurrentRendererTime()
    currentSchedulerTime = currentRendererTime

    <span class="hljs-keyword">if</span> (enableSchedulerTracing) {
      <span class="hljs-comment">// Don&apos;t update pending interaction counts for suspense timeouts,</span>
      <span class="hljs-comment">// Because we know we still need to do more work in this case.</span>
      suspenseDidTimeout = <span class="hljs-literal">true</span>
      flushRoot(root, suspendedExpirationTime)
      suspenseDidTimeout = <span class="hljs-literal">false</span>
    } <span class="hljs-keyword">else</span> {
      flushRoot(root, suspendedExpirationTime)
    }
  }
}</code></pre>
<p>&#x5176;&#x4E2D;<code>scheduleTimeout</code>&#x662F;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x7684;<code>setTimout</code></p><h5 id="&#x771F;&#x6B63;&#x7684;-sequense">&#x771F;&#x6B63;&#x7684; sequense</h5><p>&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5224;&#x65AD;&#x5C31;&#x662F;&#x771F;&#x6B63;&#x7684;&#x6302;&#x8D77;&#x4EFB;&#x52A1;&#x4E86;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;<code>suquense</code>&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x5176;&#x5B9E;&#x505A;&#x7684;&#x4E8B;&#x60C5;&#x8DDF;&#x4E0A;&#x9762;&#x4E24;&#x4E2A;&#x5DEE;&#x4E0D;&#x591A;&#xFF0C;&#x552F;&#x4E00;&#x7684;&#x533A;&#x522B;&#x662F;&#x8C03;&#x7528;<code>onSuspend</code>&#x7684;&#x65F6;&#x5019;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x80AF;&#x5B9A;&#x662F;&#x5927;&#x4E8E;&#x7B49;&#x4E8E;&#x96F6;&#x7684;&#x3002;&#x4EE3;&#x8868;&#x7740;&#x4ED6;&#x662F;&#x7ACB;&#x523B;&#x5C31;&#x8981;<code>commit</code>&#x8FD8;&#x662F;&#x5728;&#x4E00;&#x4E2A;<code>timeout</code>&#x4E4B;&#x540E;&#x518D;<code>commit</code>&#x3002;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;<code>onTimeout</code>&#x6700;&#x540E;&#x662F;<code>flushRoot</code>&#xFF0C;&#x5C31;&#x662F;&#x4EE5;<code>Sync</code>&#x7684;&#x65B9;&#x5F0F;&#x8C03;&#x7528;<code>performWork</code></p><h5 id="&#x6700;&#x540E;">&#x6700;&#x540E;</h5><p>&#x5982;&#x679C;&#x4EE5;&#x4E0A;&#x903B;&#x8F91;&#x90FD;&#x6CA1;&#x6709;&#xFF0C;&#x90A3;&#x4E48;&#x76F4;&#x63A5;&#x8C03;&#x7528;<code>onComplete</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onComplete</span>(<span class="hljs-params">
  root: FiberRoot,
  finishedWork: Fiber,
  expirationTime: ExpirationTime,
</span>) </span>{
  root.pendingCommitExpirationTime = expirationTime
  root.finishedWork = finishedWork
}</code></pre>
</div><div class="api-method-code"><div class="api-method-sample" data-lang="js" data-name="JavaScript"><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">renderRoot</span>(<span class="hljs-params">root, isYieldy, isExpired</span>) </span>{
  !!isWorking
    ? invariant(
        <span class="hljs-literal">false</span>,
        <span class="hljs-string">&apos;renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.&apos;</span>,
      )
    : <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>
  isWorking = <span class="hljs-literal">true</span>
  ReactCurrentOwner$<span class="hljs-number">2.</span>currentDispatcher = Dispatcher

  <span class="hljs-comment">// console.log(isYieldy, isExpired)</span>
  logRootTimes(<span class="hljs-string">&apos;start&apos;</span>, root)

  <span class="hljs-keyword">var</span> expirationTime = root.nextExpirationTimeToWorkOn
  <span class="hljs-built_in">console</span>.log(expirationTime, nextRenderExpirationTime)

  <span class="hljs-keyword">var</span> prevInteractions = <span class="hljs-literal">null</span>
  <span class="hljs-keyword">if</span> (enableSchedulerTracing) {
    prevInteractions = tracing.__interactionsRef.current
    tracing.__interactionsRef.current = root.memoizedInteractions
  }

  <span class="hljs-comment">// Check if we&apos;re starting from a fresh stack, or if we&apos;re resuming from</span>
  <span class="hljs-comment">// previously yielded work.</span>
  <span class="hljs-keyword">if</span> (
    expirationTime !== nextRenderExpirationTime ||
    root !== nextRoot ||
    nextUnitOfWork === <span class="hljs-literal">null</span>
  ) {
    <span class="hljs-comment">// Reset the stack and start working from the root.</span>
    resetStack()
    nextRoot = root
    nextRenderExpirationTime = expirationTime
    nextUnitOfWork = createWorkInProgress(
      nextRoot.current,
      <span class="hljs-literal">null</span>,
      nextRenderExpirationTime,
    )
    root.pendingCommitExpirationTime = NoWork
  }

  <span class="hljs-keyword">var</span> didFatal = <span class="hljs-literal">false</span>

  startWorkLoopTimer(nextUnitOfWork)

  <span class="hljs-keyword">do</span> {
    <span class="hljs-keyword">try</span> {
      workLoop(isYieldy)
    } <span class="hljs-keyword">catch</span> (thrownValue) {
      <span class="hljs-keyword">if</span> (nextUnitOfWork === <span class="hljs-literal">null</span>) {
        <span class="hljs-comment">// This is a fatal error.</span>
        didFatal = <span class="hljs-literal">true</span>
        onUncaughtError(thrownValue)
      } <span class="hljs-keyword">else</span> {
        {
          <span class="hljs-comment">// Reset global debug state</span>
          <span class="hljs-comment">// We assume this is defined in DEV</span>
          resetCurrentlyProcessingQueue()
        }

        <span class="hljs-keyword">var</span> failedUnitOfWork = nextUnitOfWork
        <span class="hljs-keyword">if</span> (<span class="hljs-literal">true</span> &amp;&amp; replayFailedUnitOfWorkWithInvokeGuardedCallback) {
          replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy)
        }
        !(nextUnitOfWork !== <span class="hljs-literal">null</span>)
          ? invariant(
              <span class="hljs-literal">false</span>,
              <span class="hljs-string">&apos;Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it.&apos;</span>,
            )
          : <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>

        <span class="hljs-keyword">var</span> sourceFiber = nextUnitOfWork
        <span class="hljs-keyword">var</span> returnFiber = sourceFiber.return
        <span class="hljs-keyword">if</span> (returnFiber === <span class="hljs-literal">null</span>) {
          didFatal = <span class="hljs-literal">true</span>
          onUncaughtError(thrownValue)
        } <span class="hljs-keyword">else</span> {
          throwException(
            root,
            returnFiber,
            sourceFiber,
            thrownValue,
            nextRenderExpirationTime,
          )
          nextUnitOfWork = completeUnitOfWork(sourceFiber)
          <span class="hljs-keyword">continue</span>
        }
      }
    }
    <span class="hljs-keyword">break</span>
  } <span class="hljs-keyword">while</span> (<span class="hljs-literal">true</span>)

  logRootTimes(<span class="hljs-number">1</span>, root)

  <span class="hljs-keyword">if</span> (enableSchedulerTracing) {
    <span class="hljs-comment">// Traced work is done for now; restore the previous interactions.</span>
    tracing.__interactionsRef.current = prevInteractions
  }

  <span class="hljs-comment">// We&apos;re done performing work. Time to clean up.</span>
  isWorking = <span class="hljs-literal">false</span>
  ReactCurrentOwner$<span class="hljs-number">2.</span>currentDispatcher = <span class="hljs-literal">null</span>
  resetContextDependences()

  <span class="hljs-comment">// Yield back to main thread.</span>
  <span class="hljs-keyword">if</span> (didFatal) {
    <span class="hljs-keyword">var</span> _didCompleteRoot = <span class="hljs-literal">false</span>
    stopWorkLoopTimer(interruptedBy, _didCompleteRoot)
    interruptedBy = <span class="hljs-literal">null</span>
    <span class="hljs-comment">// There was a fatal error.</span>
    {
      resetStackAfterFatalErrorInDev()
    }
    nextRoot = <span class="hljs-literal">null</span>
    onFatal(root)
    <span class="hljs-keyword">return</span>
  }

  <span class="hljs-keyword">if</span> (nextUnitOfWork !== <span class="hljs-literal">null</span>) {
    <span class="hljs-keyword">var</span> _didCompleteRoot2 = <span class="hljs-literal">false</span>
    stopWorkLoopTimer(interruptedBy, _didCompleteRoot2)
    interruptedBy = <span class="hljs-literal">null</span>
    onYield(root)
    <span class="hljs-keyword">return</span>
  }

  <span class="hljs-comment">// We completed the whole tree.</span>
  <span class="hljs-keyword">var</span> didCompleteRoot = <span class="hljs-literal">true</span>
  stopWorkLoopTimer(interruptedBy, didCompleteRoot)
  <span class="hljs-keyword">var</span> rootWorkInProgress = root.current.alternate
  !(rootWorkInProgress !== <span class="hljs-literal">null</span>)
    ? invariant(
        <span class="hljs-literal">false</span>,
        <span class="hljs-string">&apos;Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue.&apos;</span>,
      )
    : <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>

  nextRoot = <span class="hljs-literal">null</span>
  interruptedBy = <span class="hljs-literal">null</span>

  <span class="hljs-keyword">if</span> (nextRenderDidError) {
    <span class="hljs-keyword">if</span> (hasLowerPriorityWork(root, expirationTime)) {
      markSuspendedPriorityLevel(root, expirationTime)
      <span class="hljs-keyword">var</span> suspendedExpirationTime = expirationTime
      <span class="hljs-keyword">var</span> rootExpirationTime = root.expirationTime
      onSuspend(
        root,
        rootWorkInProgress,
        suspendedExpirationTime,
        rootExpirationTime,
        <span class="hljs-number">-1</span>, <span class="hljs-comment">// Indicates no timeout</span>
      )
      <span class="hljs-keyword">return</span>
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (!root.didError &amp;&amp; !isExpired) {
      root.didError = <span class="hljs-literal">true</span>
      <span class="hljs-keyword">var</span> _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime)
      <span class="hljs-keyword">var</span> _rootExpirationTime = (root.expirationTime = Sync)
      onSuspend(
        root,
        rootWorkInProgress,
        _suspendedExpirationTime,
        _rootExpirationTime,
        <span class="hljs-number">-1</span>, <span class="hljs-comment">// Indicates no timeout</span>
      )
      <span class="hljs-keyword">return</span>
    }
  }

  <span class="hljs-keyword">if</span> (!isExpired &amp;&amp; nextLatestAbsoluteTimeoutMs !== <span class="hljs-number">-1</span>) {
    <span class="hljs-comment">// The tree was suspended.</span>
    <span class="hljs-keyword">var</span> _suspendedExpirationTime2 = expirationTime
    markSuspendedPriorityLevel(root, _suspendedExpirationTime2)

    <span class="hljs-keyword">var</span> earliestExpirationTime = findEarliestOutstandingPriorityLevel(
      root,
      expirationTime,
    )
    <span class="hljs-keyword">var</span> earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime)
    <span class="hljs-keyword">if</span> (earliestExpirationTimeMs &lt; nextLatestAbsoluteTimeoutMs) {
      nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs
    }

    <span class="hljs-keyword">var</span> currentTimeMs = expirationTimeToMs(requestCurrentTime())
    <span class="hljs-keyword">var</span> msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs
    msUntilTimeout = msUntilTimeout &lt; <span class="hljs-number">0</span> ? <span class="hljs-number">0</span> : msUntilTimeout

    <span class="hljs-comment">// <span class="hljs-doctag">TODO:</span> Account for the Just Noticeable Difference</span>

    <span class="hljs-keyword">var</span> _rootExpirationTime2 = root.expirationTime
    onSuspend(
      root,
      rootWorkInProgress,
      _suspendedExpirationTime2,
      _rootExpirationTime2,
      msUntilTimeout,
    )
    logRootTimes(<span class="hljs-number">2</span>, root)
    <span class="hljs-keyword">return</span>
  }

  logRootTimes(<span class="hljs-number">3</span>, root)

  <span class="hljs-comment">// Ready to commit.</span>
  onComplete(root, rootWorkInProgress, expirationTime)
}</code></pre>
</div></div></div>



<p><a href="perform-unit-of-work.html"><code>performUnitOfWork</code></a></p><p><a href="render-root/throw-exception.html"><code>throwException</code></a></p>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
<div id="disqus_thread"></div>
<script>
  /**
   *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
   *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
  /*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
  ;(function() {
    // DON'T EDIT BELOW THIS LINE
    var d = document,
      s = d.createElement('script')
    s.src = 'https://react-source-code.disqus.com/embed.js'
    s.setAttribute('data-timestamp', +new Date())
    ;(d.head || d.body).appendChild(s)
  })()
</script>
<noscript
  >Please enable JavaScript to view the
  <a href="https://disqus.com/?ref_noscript"
    >comments powered by Disqus.</a
  ></noscript
>

            </div>

            

        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"renderRoot","level":"1.4.6","depth":2,"next":{"title":"throwException","level":"1.4.6.1","depth":3,"path":"book/flow/render-root/throw-exception.md","ref":"book/flow/render-root/throw-exception.md","articles":[]},"previous":{"title":"performUnitOfWork","level":"1.4.5","depth":2,"path":"book/flow/perform-unit-of-work.md","ref":"book/flow/perform-unit-of-work.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-api"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["weibo","google","twitter","weibo","instapaper"]},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-api":{"languages":[],"split":true,"theme":"light"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"React源码解析","language":"zh-hans","gitbook":"*"},"file":{"path":"book/flow/render-root.md","mtime":"2018-11-16T11:35:30.755Z","type":"markdown"},"gitbook":{"version":"3.2.0","time":"2019-07-08T12:28:32.264Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-api/theme-api.js"></script>
        
    

    </body>
</html>

